//
//  UserInfo.swift
//  HoneyBee
//
//  Created by point on 2018/1/29.
//  Copyright © 2018年 point. All rights reserved.
//

import UIKit
private let kAccountPath =  NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true).first! + "/userAccount.plist"
class UserInfo: NSObject {
    static let shareInstance : UserInfo = {
        let tools = UserInfo()
        return tools
    }()
    
    func userModel() -> UserModel {
        
        
        let fileManager = FileManager.default
        let exist = fileManager.fileExists(atPath: kAccountPath)
        if exist {
            guard let model = NSKeyedUnarchiver.unarchiveObject(withFile: kAccountPath)else {
                return UserModel()
            }
            return model as! UserModel
        }else {
            return UserModel()
        }
        
    }
    
    func setUserModel(model:UserModel)  {
        NSKeyedArchiver.archiveRootObject(model, toFile: kAccountPath)
    }
}
